package com.kikcn.demo;


import net.sf.ehcache.Cache;
import net.sf.ehcache.CacheManager;
import net.sf.ehcache.Element;
import org.apache.log4j.Logger;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import java.nio.Buffer;
import java.nio.ByteBuffer;
import java.nio.channels.Channel;
import java.nio.channels.FileChannel;


/**
 * Created by kikcn on 2015/4/18.
 */
public class Main {
    public static final Logger logger = Logger.getLogger(Main.class);

    public static void main(String[] args) throws InterruptedException {
        ApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");
        CacheManager cacheManager = (CacheManager) context.getBean("demoEhcacheManager");
//        //URL url = Main.class.getResource("/resources/cache/ehcache-demo.xml");
//        //CacheManager cacheManager=new CacheManager(url);
        // String[] cacheNames=cacheManager.getCacheNames();
        Cache globalCache = cacheManager.getCache("globalCache");
        Cache demoCache=cacheManager.getCache("demoCache");
        Element ele = globalCache.get("global");
        if (ele ==null) {
            System.out.println("Not found....");
            byte[] data=new byte[1024*1024*100];
            ele = new Element("global", data);
            globalCache.put(ele);
        } else {
            System.out.println("Found.." + ele.getObjectValue().toString());
        }

    }

    public static void main2(String[] args) {

    }
}
